﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControl_ControlForm : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["MenuID"] != null)
            {
                BindToRepeater(Request.QueryString["MenuID"].ToString());
                if (Request.QueryString["MenuID"].ToString() == "QTHT")
                {
                    ltTitle.Text = "QUẢN TRỊ HỆ THỐNG";
                }
                else if (Request.QueryString["MenuID"].ToString() == "DLN")
                {
                    ltTitle.Text = "QUẢN LÝ DANH MỤC";
                }
                else if (Request.QueryString["MenuID"].ToString() == "NVK")
                {
                    ltTitle.Text = "NGHIỆP VỤ HÀNG NGÀY";
                }
                else if (Request.QueryString["MenuID"].ToString() == "ICT")
                {
                    ltTitle.Text = "IN CHỨNG TỪ";
                }
                else if (Request.QueryString["MenuID"].ToString() == "XMNVK")
                {
                    ltTitle.Text = "XÁC MINH NGHIỆP VỤ KHO";
                }
                else if (Request.QueryString["MenuID"].ToString() == "BC")
                {
                    ltTitle.Text = "BÁO CÁO";
                }
                else if (Request.QueryString["MenuID"].ToString() == "LKDL")
                {
                    ltTitle.Text = "LIỆT KÊ DỮ LIỆU";
                }
                else if (Request.QueryString["MenuID"].ToString() == "TI")
                {
                    ltTitle.Text = "TIỆN ÍCH";
                }

            }
            else
            {
               
            }
        }
    }
    void BindToRepeater(string MenuID)
    {
        dt = new ClassExecute.ClassExecute();
        try
        {
          
            DataTable db = dt.Get_Data_DataTable(str, ref error, "tu_getMenuFilterMenuID", CommandType.StoredProcedure,
                new SqlParameter("@TypeID", Session["UserType"].ToString()),
                new SqlParameter("@MenuID", MenuID),
                new SqlParameter("@Name", Session["lang"].ToString())
                );
            dlForm.DataSource = db;
            dlForm.DataBind();
           
        }
         catch(Exception ex)
        {
             
            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            dt.WriteErrorLog(Server.MapPath(webapp4U.Globals.LogUrl()), ex.Message, method);     
        }    
        
    }
}